package com.flute.icrawler.app.processor;

import com.flute.icrawler.framework.framework.CrawlUrl;
import com.flute.icrawler.framework.framework.IProcessor;

public abstract class AbstractProcessor implements IProcessor {

	public String ID = "";

	public int minThreadCount;

	public int maxThreadCount;

	public String dependencyIDs = "";

	public void addDependencyID(int ID) {
		if (null == dependencyIDs || "".equalsIgnoreCase(dependencyIDs)) {
			dependencyIDs = "" + ID;
		} else {
			dependencyIDs = dependencyIDs + "," + ID;
		}

	}

	public String getDependencyIDs() {
		return dependencyIDs;
	}

	public String getName() {
		return this.getClass().getName() + "-" + this.ID;
	}

	@Override
	public abstract void process(CrawlUrl url);

	@Override
	public boolean equals(Object obj) {
		// TODO Auto-generated method stub
		if (obj instanceof AbstractProcessor) {
			AbstractProcessor processor = (AbstractProcessor) obj;
			if (processor.ID == this.ID
					&& processor.getClass().getName().equals(
							this.getClass().getName())) {
				return true;
			}
		}
		return false;
	}
}
